package com.jason.algorithm;

import java.util.HashMap;
import java.util.Map;

public class AlgorithmBase {


    public static boolean hasRepeatNum(int [] array) {
        //查询时间复杂度O(1)   int [] nums = new int[max];
        Map<String, Object> map = new HashMap<>();
        for (int i = 0; i < array.length; i ++) {
            //不含key nums[i]  则该数不重复
            if (!map.containsKey(String.valueOf(array[i]))) {
                map.put(String.valueOf(array[i]), array[i]);
            } else {
                //该数重复
                return false;
            }

        }
        return true;
    }

    public static void main(String[] args) {
        int [] array = {15,3,2,5,9,4,6};
        System.out.println(AlgorithmBase.hasRepeatNum(array));
    }

}
